<template>
  <div class="search">
    <f-form ref="form" :action="api.bps" :form-key="this.formItem.projectSupplierId">
      <f-form-item label="包商1" type="select" :data="api.bps.getSupplierList" label-key="supplierName"
                   value-key="supplierId"
                   :value="formItem.supplierId1" name="supplierId1" :showSearch="true"/>
      <f-form-item label="包商2" type="select" :data="api.bps.getSupplierList" label-key="supplierName"
                   value-key="supplierId"
                   :value="formItem.supplierId2" name="supplierId2" :showSearch="true"/>
      <f-form-item label="包商3" type="select" :data="api.bps.getSupplierList" label-key="supplierName"
                   value-key="supplierId"
                   :value="formItem.supplierId3" name="supplierId3" :showSearch="true"/>
      <f-form-item label="包商4" type="select" :data="api.bps.getSupplierList" label-key="supplierName"
                   value-key="supplierId"
                   :value="formItem.supplierId4" name="supplierId4" :showSearch="true"/>
      <f-form-item label="包商5" type="select" :data="api.bps.getSupplierList" label-key="supplierName"
                   value-key="supplierId"
                   :value="formItem.supplierId5" name="supplierId5" :showSearch="true"/>
      <f-form-item label="包商6" type="select" :data="api.bps.getSupplierList" label-key="supplierName"
                   value-key="supplierId"
                   :value="formItem.supplierId6" name="supplierId6" :showSearch="true"/>
      <f-form-item label="包商7" type="select" :data="api.bps.getSupplierList" label-key="supplierName"
                   value-key="supplierId"
                   :value="formItem.supplierId7" name="supplierId7" :showSearch="true"/>
      <f-form-item label="包商8" type="select" :data="api.bps.getSupplierList" label-key="supplierName"
                   value-key="supplierId"
                   :value="formItem.supplierId8" name="supplierId8" :showSearch="true"/>
      <f-form-item label="包商9" type="select" :data="api.bps.getSupplierList" label-key="supplierName"
                   value-key="supplierId"
                   :value="formItem.supplierId9" name="supplierId9" :showSearch="true"/>
      <f-form-item label="包商10" type="select" :data="api.bps.getSupplierList" label-key="supplierName"
                   value-key="supplierId" :value="formItem.supplierId10" name="supplierId10" :showSearch="true"/>
    </f-form>
  </div>
</template>
<script>
  import api from './js/apiProjectSupplier'

  export default {
    name: 'bmpForm',
    props: {
      detailsParams: {}
    },
    data() {
      return {
        dataArrayTest: [{ label: '包商1', value: 1 }, { label: '包商2', value: 2 }, {
          label: '包商3',
          value: 3
        }, { label: '下拉选需要实现搜索', value: 4 }],
        refs: this.$refs,
        api: Object.assign(api, this.api),
        isAdd: true,//是否是添加模式
        loaded: false,//是否加载完成
        formItem: this.getFormItem()
      }
    },
    methods: {
      getFormItem() {
        return {
          projectSupplierId: '',
          supplierId1: '',
          supplierId2: '',
          supplierId3: '',
          supplierId4: '',
          supplierId5: '',
          supplierId6: '',
          supplierId7: '',
          supplierId8: '',
          supplierId9: '',
          supplierId10: '',
          projectId: '',
          majorCode: '',
          packageNo: ''
        }
      },
      //表单赋值
      setData(data) {
        this.$refs.form.resetFields()
        this.formItem = this.getFormItem()
        if (data && data.projectSupplierId) {
          let params = {
            projectSupplierId: data.projectSupplierId
          }
          this.refs['form'].getDetails(params, (data) => {
            this.formItem = data
            this.loaded = true
          })
          this.isAdd = false
        } else {
          this.loaded = true
        }
      },
      //提交表单
      handleSubmit(callback) {
        this.$refs.form.submit(this.detailsParams, callback)
      }
    },
    created() {
    },
    components: {}
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
